import os

# 指定原始文件路径和拆分后文件夹的路径
original_file_path = 'findMysqlTable.txt'
split_folder_path = 'split_files'

# 创建拆分文件夹
os.makedirs(split_folder_path, exist_ok=True)

# 每个文件的行数
lines_per_file = 2000

# 逐行读取原始文件，并拆分为多个文件
with open(original_file_path, 'r') as file:
    file_index = 1
    line_count = 0
    split_file = open(f'{split_folder_path}/split_file_{file_index}.sql', 'w')
    for line in file:
        if ("job_tju" in line):
            continue
        split_file.write(line)
        line_count += 1
        if line.endswith(");\n"):
            if line_count >= lines_per_file:
                split_file.close()
                file_index += 1
                split_file = open(f'{split_folder_path}/split_file_{file_index}.sql', 'w')
                line_count = 0
        
    split_file.close()
